package com.yanqu.road.server.gameplayer.module.activity.horserun.event;

import com.yanqu.road.entity.activity.horserun.HorseRunUserGamingData;
import com.yanqu.road.entity.activity.horserun.config.HorseRunEventConfig;
import com.yanqu.road.entity.enums.activity.horserun.eHorseRunAttrEnum;
import com.yanqu.road.logic.activity.horserun.HorseRunConfig;
import com.yanqu.road.pb.activity.HorseRunProto;
import com.yanqu.road.server.manger.activity.horserun.HorseRunMgr;

import java.util.ArrayList;
import java.util.List;

public class HorseRunReduceAllAttrEvent extends HorseRunBaseEvent{
    @Override
    public HorseRunProto.EventResult.Builder meet(HorseRunUserGamingData userGamingData, HorseRunConfig config, HorseRunEventConfig eventConfigById) {
        HorseRunProto.EventResult.Builder builder = HorseRunProto.EventResult.newBuilder();
        int eventId = eventConfigById.getId();

        builder.setError(0);

        int addNum = eventConfigById.getParamList().get(0);
        addNum = -addNum;

        for (eHorseRunAttrEnum eHorseRunAttrEnum:eHorseRunAttrEnum.values()){
            int addType = eHorseRunAttrEnum.getValue();

            userGamingData.addBaseAttr(addType,addNum);
            HorseRunProto.AttrRiseResult.Builder attrAddBuild = HorseRunProto.AttrRiseResult.newBuilder();
            attrAddBuild.setType(addType).setValue(addNum);
            builder.addAttrAdd(attrAddBuild);
        }
        List<Integer> logParam = new ArrayList<>();
        logParam.add(addNum);

        //加到日志里面
        addUserLog(userGamingData,config,1,eventId,logParam,builder);
        //完成
        eventDone(userGamingData);

        return builder;
    }

}
